/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package common.model;

/**
 *
 * @author nicolas
 */
public class Visitor {

    //Variable declarations
    private String userName = "UserName";
    private Position position;
    private boolean guide = false;

    /**
     * Copy constructor
     * @param visitor
     */
    public Visitor(Visitor visitor) {
        this.position = new Position();
        this.userName = visitor.userName;
        this.setX(visitor.getX());
        this.setZ(visitor.getZ());
        this.setRotation(visitor.getRotation());
        this.setGuide(visitor.isGuide());
    }

    public Visitor(String userName, Position position) {
        this.userName = userName;
        this.position = position;
    }
    public Visitor(String userName, double x,double z, double rot) {
        this.userName = userName;
        this.position = new Position();
        this.setX(x);
        this.setZ(z);
        this.setRotation(rot);

    }

    public Visitor(String userName, double x,double z, double rot, boolean guide) {
        this(userName, x, z, rot);
        this.position = new Position();
        this.guide = guide;
    }

    public Visitor() {
        this("NONAME", -99.99, -99.99, -360, false);
    }

    public double getDistFrom(Visitor vs) {
        return Math.sqrt( Math.pow(this.getX() - vs.getX(), 2) + Math.pow(this.getZ() - vs.getZ(), 2) );
    }

    @Override
    public String toString() {
        return this.userName;
    }

    @Override
    public boolean equals(Object obj) {
        if(this.userName.equals(((Visitor)obj).getUserName())){
            return true;
        }
        return false;
    }

    public double getX() {
        return position.getX();
    }

    public double getZ(){
        return position.getZ();
    }
    public double getRotation(){
        return position.getRotation();
    }
    public void setX(double x){
        position.setX(x);
    }
    public void setZ(double z){
        position.setZ(z);
    }
    public void setRotation(double rot){
        position.setRotation(rot);
    }
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public boolean isGuide() {
        return guide;
    }

    public void setGuide(boolean guide) {
        this.guide = guide;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 23 * hash + (this.userName != null ? this.userName.hashCode() : 0);
        return hash;
    }

    public String getCompleteInfo(){
        return "Name: " + this.userName + " X:" + this.getX() + " Z:" + this.getZ() + " Rot:" + this.getRotation() + " isGuide:" + this.isGuide();
    }
}
